#include <boost/bind.hpp>
#include <boost/function.hpp>

#include "button.hpp"
#include "formatter.hpp"
#include "label.hpp"
#include "map_display.hpp"
#include "unit.hpp"
#include "unit_summary_dialog.hpp"
#include "unit_type.hpp"

namespace game_dialogs {

unit_summary_dialog::unit_summary_dialog(map_display& m, world& w, unit_ptr u)
  : dialog(800, 100, 224, 200), display_(m), world_(w), unit_(u)
{
	init();
}

void unit_summary_dialog::init()
{
	clear();
	using namespace gui;
	set_padding(10);

	const SDL_Color color = { 0xFF, 0xFF, 0xFF, 0xFF };

	add_widget(widget_ptr(new label(unit_->type()->description(), color, 24)), 10, 20);
	add_widget(widget_ptr(new label(formatter() << "Moves: " << (unit_->movement_left()/10) << "/" << (unit_->total_movement()/10), color)));
	if(unit_->type()->can_build_city() && unit_->movement_left()) {
		button_ptr build_city(new button(
		  widget_ptr(new label("Build City", color)),
		  boost::bind(&map_display::build_city, &display_)));
		add_widget(build_city);
	}
}

}
